import 'package:json_annotation/json_annotation.dart';

part 'response_with_object.g.dart';

@JsonSerializable(genericArgumentFactories: true)
class ResponseWithObject<T> extends Object {
  @JsonKey(name: 'code')
  int code;

  @JsonKey(name: 'msg')
  String msg;

  @JsonKey(name: 'data')
  T data;

  ResponseWithObject(
    this.code,
    this.msg,
    this.data,
  );

  factory ResponseWithObject.fromJson(
          Map<String, dynamic> srcJson, T Function(dynamic json) fromJsonT) =>
      _$ResponseWithObjectFromJson(srcJson, fromJsonT);

  Map<String, dynamic> toJson(
          ResponseWithObject<T> instance, Object? Function(T value) toJsonT) =>
      _$ResponseWithObjectToJson(instance, toJsonT);

  @override
  String toString() {
    return 'ResponseWithObject{code: $code, msg: $msg, data: $data}';
  }
}
